<template>
  <div>
    <el-dialog
      v-model="props.visible"
      title=""
      width="80%"
      @close="handleCancel"
    >
      <el-tabs
        v-model="activeName"
        type="card"
        class="demo-tabs"
        v-loading="loading"
        @tab-click="handleClick"
      >
        <el-tab-pane label="产品明细" name="first">
          <el-table :data="produceProductList" border>
            <el-table-column
              label="序号"
              width="60"
              type="index"
              align="center"
            />
            <el-table-column
              label="产品序列号"
              min-width="120"
              prop="productNo"
              align="center"
            ></el-table-column>
            <el-table-column
              label="订单数量"
              width="120"
              prop="produceCount"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="书刊编码"
              min-width="120"
              prop="bookCode"
              align="center"
            ></el-table-column>
            <el-table-column
              label="书刊名称"
              min-width="160"
              prop="bookName"
              align="center"
            ></el-table-column>

            <el-table-column
              label="产品品种"
              prop="breedType"
              min-width="120"
              align="center"
            ></el-table-column>
            <el-table-column
              label="清样编号"
              min-width="120"
              prop="sampleNo"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="文件号"
              min-width="120"
              prop="fileNo"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="书号"
              min-width="120"
              prop="bookNo"
              align="center"
            ></el-table-column>
            <el-table-column
              label="定价"
              min-width="120"
              prop="fixPrice"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="组成"
              min-width="120"
              prop="composition"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="ems_order_make_up_fm"
                  :value="scope.row.composition"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="印色"
              min-width="100"
              prop="printColor"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="ems_order_print_color"
                  :value="scope.row.printColor"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="颜色"
              width="130"
              prop="color"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="ems_produce_color"
                  :value="scope.row.color"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="纸型"
              width="120"
              prop="paperType"
              align="center"
            >
            <template #default="scope">
                <dict-tag
                  :options="mes_paper_type"
                  :value="scope.row.paperType"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="纸张编码"
              width="120"
              prop="paperNo"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="纸张名称"
              width="120"
              prop="paperName"
              align="center"
            />
            <el-table-column
              label="覆膜"
              width="120"
              prop="coverFilm"
              align="center"
            >
            <template #default="scope">
                <dict-tag
                  :options="ems_produce_cover_film"
                  :value="scope.row.coverFilm"
                />
              </template>
            </el-table-column>

            <el-table-column
              label="喷码"
              width="100"
              prop="marking"
              align="center"
            >
            <template #default="scope">
                <dict-tag
                  :options="ems_produce_marking"
                  :value="scope.row.marking"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="联版数量"
              width="120"
              prop="lianbanCount"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="内文承印厂"
              width="120"
              prop="textPrinter"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="科目"
              width="100"
              prop="subjectType"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="ems_workshop_subject_type"
                  :value="scope.row.subjectType"
                />
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="纸张管理" name="second">
          <el-table :data="producePaperList" ref="producePaperListRef" border>
            <el-table-column
              label="序号"
              width="60"
              type="index"
              align="center"
            />
            <el-table-column
              label="纸张类型"
              prop="type"
              width="120"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="mes_paper_material"
                  :value="scope.row.type"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="纸张名称"
              min-width="160"
              prop="paperName"
              align="center"
            />
            <el-table-column
              label="纸型"
              min-width="120"
              prop="paperType"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="mes_paper_type"
                  :value="scope.row.paperType"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="定量"
              min-width="80"
              prop="weight"
              align="center"
            ></el-table-column>
            <el-table-column
              label="规格"
              min-width="120"
              prop="specifications"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="mes_paper_specs"
                  :value="scope.row.specifications"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="幅宽(mm)"
              min-width="120"
              prop="length"
              align="center"
            ></el-table-column>
            <el-table-column
              label="单位"
              min-width="80"
              prop="unit"
              align="center"
            >
              <template #default="scope">
                <dict-tag :options="mes_paper_unit" :value="scope.row.unit" />
              </template>
            </el-table-column>
            <el-table-column
              label="库存数量"
              min-width="110"
              prop="amount"
              align="center"
            ></el-table-column>
            <el-table-column
              label="数量"
              min-width="110"
              prop="reamAmount"
              align="center"
            ></el-table-column>
            <el-table-column
              label="品牌"
              min-width="120"
              prop="brand"
              align="center"
            >
              <template #default="scope">
                <dict-tag :options="mes_paper_brand" :value="scope.row.brand" />
              </template>
            </el-table-column>
            <el-table-column
              label="裁切尺寸"
              width="120"
              prop="size"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="纸张编码"
              min-width="120"
              prop="paperNo"
              align="center"
            ></el-table-column>
            <el-table-column
              label="纸张序列号"
              min-width="120"
              prop="paperProduceNo"
              align="center"
            ></el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="印刷管理" name="third">
          <el-table :data="producePrintList" ref="producePrintListRef" border>
            <el-table-column
              label="序号"
              width="60"
              type="index"
              align="center"
            />
            <el-table-column
              label="印刷序列号"
              min-width="120"
              prop="printProduceNo"
              align="center"
            ></el-table-column>
            <el-table-column
              label="纸型"
              width="100"
              prop="paperType"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="mes_paper_type"
                  :value="scope.row.paperType"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="定量"
              width="60"
              prop="weight"
              align="center"
            ></el-table-column>
            <el-table-column
              label="印数"
              width="100"
              prop="printAmount"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="用纸令数"
              width="80"
              prop="reamAmount"
              align="center"
            ></el-table-column>
            <el-table-column
              label="损耗系数(%)"
              width="100"
              prop="lossCoefficient"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="损耗令数"
              width="80"
              prop="lossReam"
              align="center"
            ></el-table-column>
            <el-table-column
              label="用纸总令数"
              width="90"
              prop="totalReamAmount"
              align="center"
            ></el-table-column>
            <el-table-column
              label="版材尺寸"
              prop="sheetSize"
              width="140"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="ems_machine_info_size"
                  :value="scope.row.sheetSize"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="另行加放"
              width="85"
              prop="lxjf"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="印色"
              width="60"
              prop="printColour"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="ems_order_print_color"
                  :value="scope.row.printColour"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="印色方式"
              prop="printColourType"
              width="120"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="ems_produce_print_colour_type"
                  :value="scope.row.printColourType"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="版材数量"
              width="85"
              prop="sheetAmount"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="活页烤版"
              prop="hykb"
              width="120"
              align="center"
            >
              <template #default="scope">
                <dict-tag :options="ems_produce_hykb" :value="scope.row.hykb" />
              </template>
            </el-table-column>
            <el-table-column
              label="工艺"
              width="120"
              prop="technologyId"
              align="center"
            >
              <template #default="scope">
                <el-select
                  clearable
                  style="width: 100%"
                  v-model="scope.row.technologyId"
                  disabled
                >
                  <el-option
                    v-for="item in technologyList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </template>
            </el-table-column>
            <el-table-column
              label="白纸裁切"
              width="120"
              prop="whitecuttingMachine"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="印刷"
              width="120"
              prop="printMachine"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="封面裁切"
              width="120"
              prop="covercuttingMachine"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="覆膜"
              width="100"
              prop="coveringMachine"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="折页"
              width="120"
              prop="foldMachine"
              align="center"
            >
            </el-table-column>

            <el-table-column
              label="装订"
              width="120"
              prop="bindingMachine"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="印刷联版图号"
              width="120"
              prop="yslbth"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="幅宽"
              width="120"
              prop="clothWidth"
              align="center"
            ></el-table-column>
            <el-table-column
              label="品牌"
              width="120"
              prop="brand"
              align="center"
            >
              <template #default="scope">
                <dict-tag :options="mes_paper_brand" :value="scope.row.brand" />
              </template>
            </el-table-column>
            <el-table-column
              label="备注"
              width="120"
              prop="remark"
              align="center"
            >
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="覆膜管理" name="fourth">
          <el-table
            :data="produceCoveringList"
            ref="produceCoveringListRef"
            border
          >
            <el-table-column
              label="序号"
              width="60"
              type="index"
              align="center"
            />
            <el-table-column
              label="覆膜序列号"
              min-width="120"
              prop="produceCoveringNo"
              align="center"
            ></el-table-column>
            <el-table-column
              label="组成"
              min-width="160"
              prop="composition"
              align="center"
            >
            </el-table-column>
            <el-table-column
              label="覆膜"
              min-width="160"
              prop="covering"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="ems_produce_cover_film"
                  :value="scope.row.covering"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="定量"
              width="120"
              prop="weight"
              align="center"
            ></el-table-column>
            <el-table-column
              label="纸型"
              width="120"
              prop="paperType"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="mes_paper_type"
                  :value="scope.row.paperType"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="规格型号"
              min-width="120"
              prop="specification"
              align="center"
            >
              <template #default="scope">
                <dict-tag
                  :options="mes_paper_specs"
                  :value="scope.row.specification"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="令数"
              width="120"
              prop="ream"
              align="center"
            ></el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>
  </div>
</template>

<script setup>
const { proxy } = getCurrentInstance();
import { parseTime } from "@/utils/ruoyi.js";
const emit = defineEmits(["cancel"]);
import { getTechnologyList } from "@/api/production/technics.js";
import { getProduceById } from "@/api/production/cover";
const {
  cover_workshop,
  ems_produce_new_past,
  ems_machine_info_size,
  ems_produce_hykb,
  mes_paper_material,
  mes_paper_specs,
  ems_produce_package_require,
  mes_paper_unit,
  ems_produce_print_colour_type,
  ems_produce_color,
  ems_produce_is_new,
  mes_paper_type,
  ems_workshop_subject_type,
  ems_order_make_up,
  ems_order_breed_type,
  ems_order_print_color,
  ems_produce_paper_size,
  ems_produce_cover_film,
  ems_produce_marking,
  ems_machine_info_waste_rate,
  mes_paper_brand,
  produce_text_printer,
  ems_order_make_up_fm,
} = proxy.useDict(
  "cover_workshop",
  "produce_text_printer",
  "mes_paper_brand",
  "ems_machine_info_waste_rate",
  "ems_produce_new_past",
  "mes_paper_unit",
  "ems_produce_package_require",
  "mes_paper_specs",
  "mes_paper_material",
  "ems_produce_hykb",
  "ems_machine_info_size",
  "ems_produce_color",
  "ems_produce_print_colour_type",
  "ems_produce_is_new",
  "ems_produce_paper_size",
  "ems_produce_cover_film",
  "ems_produce_marking",
  "mes_paper_type",
  "ems_order_print_color",
  "ems_order_make_up",
  "ems_workshop_subject_type",
  "ems_order_breed_type",
  "ems_order_make_up_fm"
);
const route = useRoute();
const props = defineProps({
  visible: {
    type: Boolean,
    default: false,
  },
  id: {
    type: [String, Number],
    default: "",
  },
  printList: {
    type: Array,
    default: () => {
      return [];
    },
  },
});
const activeName = ref("first");

const handleClick = (tab, event) => {
  console.log(tab, event);
};
const bookCode = ref("");
const listBPT = ref([]);
const loading = ref(true);
const dataList = ref([]);
const technologyList = ref([]);
const data = reactive({
  produceProductList: [], // 产品
  producePaperList: [], // 纸张
  producePrintList: [], // 印刷
  produceCoveringList: [], // 覆膜
  producePieceList: [],
  form: {},
});

const {
  form,
  produceProductList,
  producePaperList,
  producePrintList,
  produceCoveringList,
  producePieceList,
} = toRefs(data);

watch(
  () => props.id,
  async (val) => {
    if (val) {
      getProduceById({ pid: val }).then((res) => {
        loading.value = false;
        produceProductList.value = res.data.produceProductList;
        producePaperList.value = res.data.producePaperList;
        producePrintList.value = res.data.producePrintList;
        producePieceList.value = res.data.producePieceList;
        produceCoveringList.value = res.data.produceCoveringList;
      });
    }
  }
);

//  获取工艺
const getTechnologyArr = () => {
  getTechnologyList({ pageNum: 1, pageSize: 100 }).then((res) => {
    technologyList.value = res.rows;
  });
};
getTechnologyArr();
const handleCancel = () => {
  emit("cancel");
};
</script>

<style lang="scss" scoped>
</style>
